#ifndef IPLINEWIDGET_H
#define IPLINEWIDGET_H

#include <QWidget>

QT_FORWARD_DECLARE_CLASS(QSpinBox)

class IpLineWidget : public QWidget
{
    Q_OBJECT
public:
    explicit IpLineWidget(QWidget *parent = 0,QColor color = QColor(255,255,255));
    ~IpLineWidget();

    QString getIpadd(int whichbox = -1);//获取当前IP地址，参数同setRange
    QString Text();//返回完整IP地址
    void setIpadd(QString str);//设置IP地址：形式-:"192.168.1.1"
    void setRange(QSize size = QSize(0,255), int whichbox = -1);//设置输入框范围值,-1代表全部,1到4分别代表各个，参数2设置对应范围数值

    void setBackground(QColor color);//设置背景颜色
    void setForeground(QColor color);//设置背景颜色

private:
    void addBox(QSpinBox *box,QLayout *layout,QWidget *nexttab = 0);
    void initStyle();

    QSpinBox *box1;
    QSpinBox *box2;
    QSpinBox *box3;
    QSpinBox *box4;
    QColor m_bgcolor;
    QColor m_fontcolor;
signals:

protected:
    bool eventFilter(QObject *, QEvent *);
public slots:

};

#endif // IPLINEWIDGET_H
